#include <bits/stdc++.h>
using namespace std;

#define int long long

int t, n, m, L, V, d, v, a, l[100471], r[100471], cnt[1000471], LL[1000471];
signed main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	scanf("%lld", &t);
	while (t--) {
		memset(cnt, 0, sizeof(cnt));
		scanf("%lld%lld%lld%lld", &n, &m, &L, &V);
		for (int i = 0; i < n; i++) {
			scanf("%lld%lld%lld", &d, &v, &a);
			if (a > 0) {
				if (v > V) {
					l[i] = d;
					r[i] = L;
				} else if (v * v + 2 * a * (L - d) > V * V) {
					l[i] = d + (V * V - v * v) / (2 * a) + 1;
					r[i] = L;
				} else {
					l[i] = r[i] = -1;
				}
			} else if (v <= V) {
				l[i] = r[i] = -1;
			} else if (a == 0) {
				l[i] = d;
				r[i] = L;
			} else {
				l[i] = d;
				r[i] = min(L, d + (v * v - V * V - 1) / (-2 * a));
			}
		}
		for (int i = 0; i < m; i++) {
			scanf("%lld", &d);
			cnt[d]++;
		}
		LL[-1] = -1;
		for (int i = 0; i <= L; i++) {
			LL[i] = (cnt[i] ? i : LL[i - 1]);
			cnt[i] += cnt[i - 1];
		}
		vector<pair<int, int>> V;
		for (int i = 0; i < n; i++) {
			if (l[i] >= 0 && cnt[l[i] - 1] < cnt[r[i]]) {
				V.emplace_back(l[i], r[i]);
			}
		}
		sort(V.begin(), V.end(), [](auto x, auto y) {
			return x.second < y.second;
		});
		int ll = -1, cnt = 0;
		for (auto [l, r] : V) {
			if (l > ll) {
				ll = LL[r];
				cnt++;
			}
		}
		printf("%lu %lld\n", V.size(), m - cnt);
	}
}
